import { listItem } from "@/api/payfee/item";
import { listProject } from "@/api/payfee/project";

export const payFeeDictMixin = {
  data(){
    return {
      //收费项目字典
      itemOptions: [],
      //收费类型字典
      projectOptions: [],
    }
  },
  created() {
    listItem().then(res => {
      this.itemOptions = res.rows;
    })
    listProject().then(res => {
      this.projectOptions = res.rows;
    })
  },
  methods: {
    // 收费项目字典翻译
    itemFormat(row, column) {
      let index = this.itemOptions.findIndex(x => x.chargeId == row.chargeId);
      if (index != -1) {
        return this.itemOptions[index].chargeName
      }
      return '';
    },
    // 收费类型字典翻译
    projectFormat(row, column) {
      let index = this.projectOptions.findIndex(x => x.projectId == row.projectId);
      if (index != -1) {
        return this.projectOptions[index].projectType
      }
      return '';
    },
  }

}
